<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>已审批产品列表---审批人</title>
    <script type="text/javascript">
      var editArticleWin;
      var articleId;
      Ext.onReady(function(){
        //产品列表---------------------------------------------------------
        //生成有关客户的Grid
        var articleDS = new Ext.data.Store({
          paramNames: {
            start: "start",
            limit: "limit"
          },
          baseParams: {
            start: 0,
            limit: 15
          },
          proxy: new Ext.data.HttpProxy({
            url: '/article/getArticles'
          }),
          reader: new Ext.data.JsonReader({
            totalProperty: 'totalProperty',
            root: 'root'
          }, [{
              name: 'id'
            },{
              name: 'auditor_name',
              mapping: 'auditor.name'
            }, {
              name: 'title'
            }, {
              name: 'sub_type'
            }])
        });
        var articleSM = new Ext.grid.CheckboxSelectionModel();
        var articleCM = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(),articleSM,{
            header: '制度标题',
            dataIndex: 'title',
            width:180
          },{
            header: '制度分类',
            dataIndex: 'sub_type',
            width:180
          }, {
            header: '修改人',
            dataIndex: 'auditor_name',
            width:90
          }]);
        
        var articleGrid =  new Ext.grid.GridPanel({
          ds: articleDS,
          cm: articleCM,
          sm: articleSM,
          width: screenWidth-330,
          height: screenHeight-320,
          iconCls: 'icon-grid',loadMask: true,
          //collapsible: true,
          //animCollapse: false,
          //frame: true,
          //title: '客户列表',
          tbar:['-',
            {
            text: '修改制度',
            width:50,
            iconCls:'editItem',
            handler:function(){
                var records = articleGrid.getSelectionModel().getSelections();
                if(records.length==0){
                  Ext.MessageBox.alert('提示信息', '请先选中一条记录后，再编辑。');
                }else{
                  //把表单添加到窗口中
                  articleId = records[0].get('id');
                  editArticleWin = new Ext.Window({
                    title: '修改制度内容',
                    layout:'fit',
                    width:767,
                    height:445,
                    closeAction:'destroy',
                    constrain:true,
                    plain: true,
                    modal: true,
                    autoLoad: {
                      url: "/article/editArticle?id=" + articleId,
                      scripts: true
                    }
                  });
                  editArticleWin.on("destroy",function(){
                    articleDS.reload();
                  });
                  editArticleWin.resizable = false;
                  editArticleWin.show();
                }
            }
          }
          ],
          bbar: new Ext.PagingToolbar({
            pageSize: pageSize,
            store: articleDS,
            displayInfo: true,
            displayMsg: "显示第 {0} 条到 {1} 条记录，一共 {2} 条",
            emptyMsg: "没有记录"
          })
        });
        articleGrid.render('article_list');
        articleDS.load();
      })
    </script>
  </head>
  <body>
    <div id="article_list"></div>
  </body>
</html>
